<template>
  <div class="user-view">

    <UserList :loading="loading" :description="closed?'主人设置了权限哦~(｡•ˇ‸ˇ•｡)':route.name==='follows'?'暂时没有关注的人哦~(｡•ˇ‸ˇ•｡)':'暂时没有粉丝哦~(｡•ˇ‸ˇ•｡)'" :total="total" :userList="userList"
              @pageChange="getOffset"></UserList>
  </div>
</template>

<script setup>
import {ref, reactive} from "vue"
import UserList from "@/components/UserList/index.vue"
import {useRoute, useRouter} from "vue-router";
import {cloudSearch} from "@/api/search/index.ts";
let total = ref(0) //数据总条数
const route = useRoute()
let loading =ref(false)
let userQuery = reactive({ //获取搜索结果请求参数
  type: 1002,//类型
  limit: 30,//返回数量限制
  offset: 0,//偏移量 （30*页码减一)
  keywords: route.query.keyWords || '',//关键词
})
let userList =ref([])
//获得歌手列表
const getData = () => {
  loading.value =true

  cloudSearch(userQuery).then(res => {
    loading.value =false
    if(!res.result.userprofiles) return false
    userList.value =res.result.userprofiles
    total.value = res.result.userprofileCount
  })
}
getData()
//获取用户列表组件的分页的页数
const getOffset = (pageNum) => {
  userQuery.offset = (pageNum - 1) * 30
  getData()
}
</script>

<style lang="less" scoped>
.user-view{
  position: relative;
  padding-bottom: 25px;
}
</style>
